<template>
  <div>
    <el-table v-loading="loading" :data="tableList" border stripe>
      <el-table-column label="评估编号" align="center" prop="evaluateNo" min-width="120" fixed="left"/>
      <el-table-column label="评估机构" align="center" prop="evaluateAgency" min-width="120" fixed="left"/>
      <el-table-column label="评估财物数量" align="center" prop="evaluateProNumber" min-width="120" fixed="left"/>
      <el-table-column label="评估财物价值" align="center" prop="evaluateProValue" min-width="120" fixed="left"/>
      <el-table-column label="评估时间" align="center" prop="evaluateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.evaluateTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="评估地点" align="center" prop="evaluatePlace" min-width="120"/>
      <el-table-column label="是否到场" align="center" prop="evaluateIsPresent" width="80">
        <template slot-scope="scope">
          {{ scope.row.evaluateIsPresent ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="$emit('handleUpdate',scope.row)"
            v-hasPermi="['sacw:evaluate:edit']"
          >
            修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sacw:evaluate:remove']"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>

</template>

<script>
import { delEvaluate, listEvaluateInfo } from '@/api/sacw/evaluate'
import ReaderFile from '@/components/ReaderFile'

export default {
  name: 'evaluateTable',
  components: { ReaderFile },
  props: {
    queryParams: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 评估表格数据
      tableList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询评估列表 */
    getList() {
      this.loading = true
      listEvaluateInfo(this.queryParams).then(response => {
        this.tableList = response.rows
        this.total = response.total
      }).finally(() => this.loading = false)
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.$modal.confirm('是否确认删除评估编号为"' + row.evaluateNo + '"的数据项？').then(() => {
        this.loading = true
        return delEvaluate(row.id)
      }).then(() => {
        this.loading = false
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
